home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Interapplication Comm / MoreAppleEvents / MoreFinderEvents.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  11.7 KB  |  366 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        MoreFinderEvents.h
  3.  
  4.     Contains:    Functions to help you build and sending Apple events to the Finder.
  5.  
  6.     Written by: Andy Bachorski    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #if PRAGMA_ONCE
  25.     #pragma once
  26. #endif
  27.  
  28. #ifndef _MORE_FINDER_EVENTS_
  29. #define _MORE_FINDER_EVENTS_
  30.  
  31.  
  32. //******************************************************************************
  33. //    A private conditionals file to setup the build environment for this project.
  34.  
  35. #include "PrivateConditionals.h"
  36.  
  37.  
  38. //**********    Universal Headers        ****************************************
  39.  
  40. #include <Aliases.h>
  41. #include <Folders.h>
  42. #include <Icons.h>
  43. #include <OSA.h>
  44. #include <Processes.h>
  45. #include <Types.h>
  46.  
  47.  
  48. //******************************************************************************
  49.  
  50. #ifdef __cplusplus
  51.     extern "C" {
  52. #endif
  53.  
  54. #if PRAGMA_IMPORT
  55.     #pragma import on
  56. #endif
  57.  
  58. #if PRAGMA_STRUCT_ALIGN
  59.     #pragma options align=mac68k
  60. #elif PRAGMA_STRUCT_PACKPUSH
  61.     #pragma pack(push, 2)
  62. #elif PRAGMA_STRUCT_PACK
  63.     #pragma pack(2)
  64. #endif
  65.  
  66. //******************************************************************************
  67.  
  68.  
  69. enum {
  70.     kFinderFileType            = 'FNDR',
  71.     kFinderCreatorType        = 'MACS',
  72.     kFinderProcessType        = 'FNDR',
  73.     kFinderProcessSignature    = 'MACS'
  74. };
  75.  
  76.  
  77. /*****************************************************************************
  78.     IMPORTANT NOTE ABOUT IDLE FUNCTIONS
  79.     
  80.     Many of the functions in this library take an AEIdleUPP as a parameter.
  81.     You can use this parameter to supply an idle function for use in the call
  82.     to AESend.
  83.     
  84.     If the idleProcUPP parameter is set to nil, no idle function is used when
  85.     AESend is called, and the send mode will be AENoReply.
  86.     
  87.     If an AEIdleUPP is supplied in the idleProcUPP parameter, it is used when
  88.     AESend is called, and the send mode will be AEWaitReply.
  89.     
  90.     There is a simple idle function supplied with this library. It's VERY simple.
  91.     It ignores any event it may receive, and returns a resonable sleep value
  92.     and a nil mouse region. This is not enough for any but the most trivial
  93.     of applications.
  94.  
  95.     If the application using these functions has windows, then the idle function
  96.     will receive update, activate, osEvt, and null events. Because of this,
  97.     you must supply a more complete and robust idle function than the defaule
  98.     idle function included with this library.
  99.     
  100.     In most cases, the events received by the idle function can simply be
  101.     sent to the application's do event routine. You will also want to supply
  102.     appropriate values for the sleep and mouseRgn parameters.
  103.     
  104.     See Inside Macintosh: Interapplicatins Communications for more about
  105.     idle functions.
  106.  
  107.  *****************************************************************************/
  108.  
  109. pascal OSErr MFESetSelectionToNone( const AEIdleUPP idleProcUPP );
  110. /*
  111.     Sets the Finder's selection to nothing by telling it to set it's 
  112.     selection to an empty list.
  113.     
  114.     See note about idle functions above.
  115. */
  116.  
  117. //******************************************************************************
  118.  
  119. pascal OSErr MFEChangeFolderViewNewSuite( const FSSpecPtr fssPtr,
  120.                                           const long viewStyle,
  121.                                           const AEIdleUPP idleProcUPP );
  122. /*
  123.     Send an Apple event to Finder 7.5 or later to set the view of the window
  124.     for the folder pointed to by the FSSpec.
  125.  
  126.     fssPtr            ==>        FSSpec for the folder whose view is to be set
  127.     viewStyle        ==>        A view constant, as defined in AERegistry.h
  128.     idleProcUPP     ==>         nil for default, or UPP for the idle function to use
  129.     
  130.     Requires that the folder's window be open, otherwise an error is returned
  131.     in the reply event.
  132.     
  133.     See note about idle functions above.
  134. */
  135.  
  136. //******************************************************************************
  137.  
  138. pascal OSErr MFEChangeFolderViewOldSuite( const FSSpecPtr fssPtr,
  139.                                           const long viewStyle,
  140.                                           const AEIdleUPP idleProcUPP );
  141. /*
  142.     Send an Apple event to Finder 7.1.1 or 7.1.2 to set the view of the window
  143.     for the folder pointed to by the FSSpec.
  144.     
  145.     fssPtr            ==>        FSSpec for the folder whose view is to be set
  146.     viewStyle        ==>        A view constant, as defined in AERegistry.h
  147.     idleProcUPP     ==>         nil for default, or UPP for the idle function to use
  148.     
  149.     Requires that the folder's window be open, otherwise an error is returned
  150.     in the reply event.
  151.     
  152.     See note about idle functions above.
  153. */
  154.  
  155. //******************************************************************************
  156.  
  157. pascal OSErr MFEChangeFolderView( const FSSpecPtr fssPtr,
  158.                                   const long viewStyle,
  159.                                   const AEIdleUPP idleProcUPP );
  160. /*
  161.     Send an Apple event to the Finder (any version) to set the view of the window
  162.     for the folder pointed to by the FSSpec.
  163.     
  164.     fssPtr            ==>        FSSpec for the folder whose view is to be set
  165.     viewStyle        ==>        A view constant, as defined in AERegistry.h
  166.     idleProcUPP     ==>         nil for default, or UPP for the idle function to use
  167.     
  168.     Requires that the folder's window be open, otherwise an error is returned
  169.     in the reply event.
  170.     
  171.     See note about idle functions above.
  172. */
  173.  
  174. //******************************************************************************
  175.  
  176. pascal OSErr MFEAddCustomIconToItem( const FSSpecPtr fssPtr,
  177.                                      const Handle theIconSuite,
  178.                                      const IconSelectorValue iconSelector,
  179.                                      const AEIdleUPP idleProcUPP );
  180. /*    
  181.     Send an Apple event to the Finder to add a custom icon to the item 
  182.     specified by the fssPtr.
  183.     
  184.     fssPtr            ==>        The item to add the custom icon to.
  185.     theIconSuite    ==>        A handle to the icon suite to install.
  186.     iconSelector    ==>        An IconSelectorValue specifying which icon types
  187.                             to add (defined in Icons.h).
  188.     idleProcUPP        ==>        A UPP for an idle function, or nil.
  189.     
  190.     See note about idle functions above.
  191. */
  192.  
  193. //******************************************************************************
  194.  
  195. pascal OSErr MFEGetItemIconSuite( const FSSpecPtr fssPtr,
  196.                              const AEIdleUPP idleProcUPP,
  197.                                    Handle     *theIconSuite );
  198. /*    
  199.     Send an Apple event to the Finder to get the icon of the item 
  200.     specified by the fssPtr.
  201.  
  202.     fssPtr            ==>        The item to get the icon from.
  203.     idleProcUPP        ==>        A UPP for an idle function, or nil.
  204.     theIconSuite    ==>        A handle into which the icon suite will be returned.
  205.     theIconSuite    <==        A handle to an icon suite.
  206.     
  207.     See note about idle functions above.
  208. */
  209.  
  210. //******************************************************************************
  211.  
  212. pascal OSErr MFEGetEveryItemOnDesktop( const AEIdleUPP idleProcUPP,
  213.                                              AEDescList *objectList );
  214. /*
  215.     Send an Apple event to the Finder to get a list of Finder-style object
  216.     for each item on the desktop. This includes files (of all types),
  217.     folders, and volumes.
  218.     
  219.     idleProcUPP        ==>        A UniversalProcPtr for an idle function, or nil.
  220.     objectList        ==>        A null AEDesc.
  221.                     <==        A list containing object descriptors,
  222.                             or a null AEDesc if an error is encountered.
  223.     
  224.     See note about idle functions above.
  225. */
  226.  
  227. //******************************************************************************
  228.  
  229. pascal OSErr MFEGetViewFontAndSize( const AEIdleUPP idleProcUPP,
  230.                                           SInt16 *font,
  231.                                           SInt16 *fontSize );
  232. /*
  233.     Send an Apple event to the Finder to get the current font and font size
  234.     as set in the Views control panel.
  235.     
  236.     idleProcUPP        ==>        A UniversalProcPtr for an idle function, or nil.
  237.     font            ==>        The font ID for the current view settings.
  238.     fontSize        ==>        The font size for the current view settings.
  239.     
  240.     You MUST supply an idle function for this routine to work, since it is
  241.     returning data.  You may use the simple handler provided in this library.
  242.     
  243.     See note about idle functions above.
  244.     
  245.     Errors
  246.     
  247.     -50        paramErr    No idle function provided.
  248. */
  249.  
  250. //******************************************************************************
  251.  
  252. pascal    OSErr    MFEUpdateItemFSS( const FSSpecPtr fssPtr );
  253. /*
  254.     Send an Apple event to the Finder to update the display of the item specified
  255.     by the FSSpec.
  256.  
  257.     fssPtr            ==>        The item whose display should be updated.
  258.  
  259.     No reply is returns, so none is asked for. Hence, no idle function is needed.
  260. */
  261.  
  262. //******************************************************************************
  263.  
  264. pascal    OSErr    MFESetProcessVisibility( const ProcessSerialNumberPtr psnPtr,
  265.                                          Boolean visible );
  266. /*
  267.     Send an Apple event to the Finder (any version) to set the visibility of
  268.     a process specified by it's name.
  269.     
  270.     processName        ==>        The process' name
  271.     visible            ==>        Make the process visible or not
  272.     
  273. */
  274.  
  275. //******************************************************************************
  276.  
  277. pascal    OSErr    MFEUpdateItemAlias( const AliasHandle aliasHandle );
  278. /*
  279.     Send an Apple event to the Finder to update the display of the item specified
  280.     by the alias.
  281.  
  282.     aliasHandle        ==>        The item whose display should be updated.
  283.  
  284.     No reply is returns, so none is asked for. Hence, no idle function is needed.
  285. */
  286.  
  287. //******************************************************************************
  288.  
  289. pascal    OSErr MFEOpenFile( const FSSpec *fssPtr );
  290. /*
  291.     Send an odoc Apple event to the Finder to open the item specified by the FSSpec.
  292.     
  293.     This routine can be used to open a file with it's creator app, launch an,
  294.     open a control panel. Pretty much open anything you can open directly in the
  295.     Finder by double-clicking.
  296.     
  297.     aliasHandle        ==>        The item whose display should be updated.
  298.     idleProcUPP        ==>        A UniversalProcPtr for an idle function, or nil.
  299.  
  300.     No reply is returns, so none is asked for. Hence, no idle function is needed.
  301. */
  302.  
  303. //******************************************************************************
  304.  
  305. pascal    OSErr    MFEMakeAliasFile( const FSSpecPtr sourceFSSPtr,
  306.                                   const FSSpecPtr destFSSPtr,
  307.                                   ConstStr63Param newName,
  308.                                   const AEIdleUPP idleProcUPP );
  309. /*
  310.     Send an Apple event to the Finder to create a new alias file at destFSSPtr
  311.     location, with the file at sourceFSSPtr as the target, with newName as it's name.
  312.     
  313.     sourceFSSPtr    ==>        The target for the new alias file.
  314.     destFSSPtr        ==>        The location for the new alias file.
  315.     newName            ==>        The name for the new alias file.
  316.  
  317.     A reference to the newly created alias file will be returned. Currently this
  318.     function ignores this result, but you could extract it if needed. You can ask
  319.     that the result be returned as a Finder style object, as an alias, or as an FSSpec.
  320.  
  321.     See note about idle functions above.
  322. */
  323.  
  324. //******************************************************************************
  325.  
  326. pascal    OSErr    MFEMoveDiskIcon( const FSSpecPtr fssPtr,
  327.                                  const Point position );
  328. /*
  329.     Send set data Apple event to the Finder to change the position of the icon
  330.     for the item specified by the FSSpec.  The Finder's display of the item is
  331.     immediately updated.
  332.     
  333.     NOTE:    The position parameter is a Point, with it's values in y/x order,
  334.             where as the Finder expects positions to be in x/y order.  This
  335.             routine changes the order for you. 
  336.     
  337.     fssPtr            ==>        The item whose position will be changed.
  338.     position        ==>        The new position for the item.
  339.     idleProcUPP        ==>        A UniversalProcPtr for an idle function, or nil.
  340.  
  341.     No reply is returns, so none is asked for. Hence, no idle function is needed.
  342. */
  343.  
  344. //******************************************************************************
  345.  
  346. #if PRAGMA_STRUCT_ALIGN
  347.     #pragma options align=reset
  348. #elif PRAGMA_STRUCT_PACKPUSH
  349.     #pragma pack(pop)
  350. #elif PRAGMA_STRUCT_PACK
  351.     #pragma pack()
  352. #endif
  353.  
  354. #ifdef PRAGMA_IMPORT_OFF
  355. #pragma import off
  356. #elif PRAGMA_IMPORT
  357. #pragma import reset
  358. #endif
  359.  
  360. #ifdef __cplusplus
  361. }
  362. #endif
  363.  
  364.  
  365. #endif // _MORE_FINDER_EVENTS_
  366.